//
//  ZHFCollectionViewCell.m
//  GoTraveling
//
//  Created by dllo on 15/12/23.
//  Copyright © 2015年 开发华佗. All rights reserved.
//

#import "ZHFCollectionViewCell.h"

#import "ZHFImageView.h"

#import "UIImageView+WebCache.m"

#import "ZHFData.h"



@implementation ZHFCollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor colorWithRed:0.98 green:0.96 blue:0.91 alpha:1];
        
        [self creatSubViews];
    }
    return self;
}

- (void)creatSubViews
{
    ZHFImageView *occupyImage = [[ZHFImageView alloc] initWithFrame:self.bounds];
    occupyImage.layer.cornerRadius = 5;
    occupyImage.layer.masksToBounds = YES;
    [self.contentView addSubview:occupyImage];
    
    self.imageView = [[UIImageView alloc] initWithFrame:self.bounds];
    self.imageView.contentMode = UIViewContentModeScaleAspectFill;
    self.imageView.layer.cornerRadius = 5;
    self.imageView.layer.masksToBounds = YES;
    [self.contentView addSubview:self.imageView];
    
    self.nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, self.frame.size.height - 20 - 30, self.frame.size.width - 20, 30)];
    self.nameLabel.font = [UIFont systemFontOfSize:18 weight:0.2];
    self.nameLabel.textColor = [UIColor whiteColor];
    [self.contentView addSubview:self.nameLabel];
}

- (void)setData:(ZHFData *)data
{
    [self.imageView sd_setImageWithURL:[NSURL URLWithString:data.image_url] placeholderImage:[UIImage imageNamed:@""]];
    self.nameLabel.text = data.name_zh_cn;
}



@end
